package org.ztr.yanai.blog.constant;

/**
 * @Author: ZhaoTR
 * @Date: Created in 2025/11/22 14:30
 * @Description: 系统常量类，统一管理系统级常量
 * @Version: 1.0
 */
public class Constants {

    private Constants() {
        throw new IllegalStateException("Constant class");
    }

    /**
     * JWT相关常量
     */
    public static class Jwt {
        public static final String TOKEN_HEADER = "Authorization";
        public static final String TOKEN_PREFIX = "Bearer ";
        public static final String SECRET_KEY = "yun-ai-blog-secret-key-2025";
        public static final long EXPIRATION_TIME = 7 * 24 * 60 * 60 * 1000L; // 7天
        public static final long REMEMBER_ME_EXPIRATION = 30 * 24 * 60 * 60 * 1000L; // 30天
    }

    /**
     * Redis相关常量
     */
    public static class Redis {
        public static final String USER_TOKEN_PREFIX = "user:token:";
        public static final String USER_INFO_PREFIX = "user:info:";
        public static final String POST_VIEW_PREFIX = "post:view:";
        public static final String POST_LIKE_PREFIX = "post:like:";
        public static final String HOT_POST_KEY = "post:hot";
        public static final long DEFAULT_EXPIRE_TIME = 24 * 60 * 60L; // 24小时
    }

    /**
     * 分页相关常量
     */
    public static class Page {
        public static final int DEFAULT_PAGE_NUM = 1;
        public static final int DEFAULT_PAGE_SIZE = 10;
        public static final int MAX_PAGE_SIZE = 100;
    }

    /**
     * 文件相关常量
     */
    public static class File {
        public static final long MAX_FILE_SIZE = 10 * 1024 * 1024L; // 10MB
        public static final String[] ALLOWED_IMAGE_TYPES = {".jpg", ".jpeg", ".png", ".gif", ".webp"};
        public static final String UPLOAD_PATH = "/uploads/";
    }

    /**
     * 正则表达式常量
     */
    public static class Regex {
        public static final String EMAIL = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+$";
        public static final String PHONE = "^1[3-9]\\d{9}$";
        public static final String USERNAME = "^[a-zA-Z0-9_]{3,20}$";
        public static final String PASSWORD = "^.{6,20}$";
    }

    /**
     * 默认值常量
     */
    public static class Default {
        public static final String DEFAULT_AVATAR = "/static/avatar/default.png";
        public static final Integer DEFAULT_POST_VIEWS = 0;
        public static final Integer DEFAULT_POST_LIKES = 0;
    }
}
